#!/usr/local/bin/perl -w

use strict;
use Bio::DB::GenBank;
use Bio::DB::Query::GenBank;

#usage perl getseq_by_query.pl "Methane monooxygenase" file.out > log.out
my $query = $ARGV[0]; 
my $query_obj = Bio::DB::Query::GenBank->new(-db => 'protein', -query => $query);

my $gb_obj = Bio::DB::GenBank->new;

my $stream_obj = $gb_obj->get_Stream_by_query($query_obj);

my $outseq_obj = Bio::SeqIO->new('-file' => ">$ARGV[1]", '-format' => 'fasta');

while(my $seq_obj = $stream_obj->next_seq){
    print $seq_obj->display_id, "\t", $seq_obj->length, "\t", $seq_obj->desc, "\n";
    $outseq_obj->write_seq($seq_obj);
}
exit;
